/**
 * Created by Toma on 2016/11/21.
 * 散点图
 */

var H5ComponentPoint = function (name, cfg) {
  var compontent = new H5ComonentBase(name, cfg);

  var base = cfg.data[0][1]; // 以第一个数据的比例为基本的100%

  $.each(cfg.data, function (idx, item) {
    var point = $('<div class="point point_' + idx + '">');
    var name = $('<div class="name">' + item[0] + '</div>');
    var rate = $('<div class="per">' + (item[1] * 100) + '%</div>');
    var per = (item[1] / base * 100) + '%';

    point.append(name)
    name.append(rate);

    point.width(per).height(per);
    item[2] && point.css('background-color', item[2]);
    item[3] !== undefined && item[4] !== undefined && point.css('left', item[3]).css('top', item[4]);


    compontent.append(point);
  })

  return compontent;
};